#!/bin/bash

CONFIG=makedist.config

if [ ! -f $CONFIG ]; then
    echo Configuration missing: $CONFIG
    echo Please set the following variables in $CONFIG
    echo in you current directory:
    echo
    echo 'VERSION=x.y.z   #use desired version'
    echo 'BRANCH="master" #or e.g. "maintained-release"'
    echo 'REMOTE="sf"     #depending on your git configuration'
    exit
else    
    . $CONFIG
fi    

# Init
OLDDIR=$(pwd)
SRCDIR=$OLDDIR/vym
TMPDIR=$OLDDIR/tmp

echo "Getting sources for: vym"  
echo "             Branch: $BRANCH"
echo "             Branch: $VERSION"
echo "  Working directory: $OLDDIR"
echo 


#Specific init:
BINDIR=$OLDDIR/binaries
DOCDIR=$TMPDIR/tex

echo Creating $BINDIR...
mkdir $BINDIR

echo Remove current content from $BINDIR...
rm $BINDIR/* 

echo Copy README.txt INSTALL.txt LICENCSE.txt...
cp $SRCDIR/README.txt $SRCDIR/INSTALL.txt $SRCDIR/LICENSE.txt $BINDIR

echo Copy pdfs... 
cp $DOCDIR/*.pdf $BINDIR

echo Copy source tarball
cp $OLDDIR/vym-$VERSION.tar.bz2 $BINDIR

echo Get binaries from OBS
osc getbinaries xUbuntu_11.10 i586
osc getbinaries xUbuntu_11.10 x86_64
osc getbinaries openSUSE_12.1 i586
osc getbinaries openSUSE_12.1 x86_64

echo Removing logfile
rm $BINDIR/rpmlint.log

ls -l $BINDIR